<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>角色管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="角色,管理">
	<meta http-equiv="description" content="This is my page">

  </head>
  
  <body>
    <center>
    	<s:form name="frm" id="frm" method="post" action="queryRole.action" namespace="/inner/role/">
    		<jsp:include page="/jsp/outward/business/common/menuLink.jsp">
    			<jsp:param name="menuLink" value="[{'name':'系统管理'},{'name':'权限管理'},{'name':'角色管理'}]"/>
    			<jsp:param name="width" value="40%"/>
    		</jsp:include>
    		
			<table cellspacing="0" width="100%">
				<tr>
					<td align="left">
						<my:hasPermission privilegeId="addRole">
						<input type="button" value="新增" class="btn" onclick="toAddRole()"/>
						</my:hasPermission>
						<my:hasPermission privilegeId="delRole">
						<input type="button" value="删除" class="btn" onclick="delRole()"/>
						</my:hasPermission>
					</td>
				</tr>
			</table>
    		
    		<table width="100%" cellspacing="1" cellpadding="3" bgcolor="#CCCCCC">
    			<tr class="tableHead" align="center">
    				<td width="10%">
    					<input type="checkbox" onclick="cbCheck(this, 'roleIds')" />
    				</td>
    				<td width="25%">
    					序号
    				</td>
    				<td width="40%">
    					角色名称
    				</td>
    				<td width="25%">
    					操作
    				</td>
    			</tr>
    			<s:iterator value="lp.list" status="s">
    				<tr align="center"
    					<s:if test="#s.index%2==0">class="tableRow2" onMouseMove="this.className='tableRow3'" onMouseOut="this.className='tableRow2'"</s:if>
						<s:else>class="tableRow1" onMouseMove="this.className='tableRow3'" onMouseOut="this.className='tableRow1'"</s:else>
    				>
    					<td>
    						<input name="roleIds" type="checkbox" value="<s:property value='id'/>" />
    					</td>
    					<td>
    						<s:property value="(pager.thisPage - 1) * pager.pageSize + #s.index + 1" />
    					</td>
    					<td>
    						<s:property value="roleName"/>
    					</td>
    					<td>
    						<my:hasPermission privilegeId="updateRole">
    						<a href="javascript:toUpdateRole(<s:property value='id' />)">修改</a>
    						</my:hasPermission>
    						<my:hasPermission privilegeId="assignPrivilege">
    						<a href="javascript:toAssignPrivilege(<s:property value='id' />)">分配权限</a>
    						</my:hasPermission>
    					</td>
    				</tr>
    			</s:iterator>
   				<jsp:include page="/common/pager/pager.jsp">
					<jsp:param name="formName" value="frm" />
					<jsp:param name="id" value="1" />
				</jsp:include>
    		</table>
    	</s:form>
    </center>
    
    <script type="text/javascript">
    function searchThis()
    {
    	$('#thisPage').val(1);
    	document.forms['frm'].submit();
    }
    
    function toAddRole()
    {
    	var url = '${CONTEXT_PATH}/inner/role/toAddRole.action';
    	openWin(url, 650, 250);
    }
    
    function toUpdateRole(id)
    {
    	var url = '${CONTEXT_PATH}/inner/role/toUpdateRole.action?role.id=' + id;
    	openWin(url, 650, 250);
    }
    
    function delRole()
    {
    	if(hasCheck('roleIds') == false)
    		return;
    	showConfirm('确认删除？', function(v){
    		if(v == true)
    		{
    			document.forms['frm'].action = '${CONTEXT_PATH}/inner/role/delRoles.action';
    			document.forms['frm'].submit();
    		}
    	});
    }
    
    function toAssignPrivilege(id)
    {
    	var url = '${CONTEXT_PATH}/inner/privilege/queryAssignPrivilegeTree.action?role.id=' + id;
    	openWin(url, 650, 700);
    }
    </script>
  </body>
</html>
